package game.util.sosc;

import java.awt.Point;

public class PointConverter implements IStringObjectStringConverter<Point>
{
    @Override
    public Point toObject(String string)
    {
        String x = string.substring("x=".length(), string.indexOf(",y="));
        String y = string.substring(string.lastIndexOf("=") + 1);
        return new Point(Integer.parseInt(x), Integer.parseInt(y));
    }

    @Override
    public String toString(Point object)
    {
        StringBuilder string = new StringBuilder();
        string.append("x=").append(object.x);
        string.append(",y=").append(object.y);
        return string.toString();
    }
}
